<!DOCTYPE html>
<html>
<#include "../head.html">

    <body>
    <div class="mc">
        <div class="mc-l">
            <!--左侧导航---{-->
            <div id="navPanelContainer">
                <div class="system-logo cd"></div>
                <!--管理员信息---{-->
                <#include "../adminInfo.html">
                    <!--管理员信息---}-->
                    <div class="nav-wrap">
                        <#include "left.html">
                    </div>
            </div>
            <!--左侧导航---}-->
        </div>
        <div class="mc-m">
            <div class="navToggle"></div>
        </div>
        <div class="mc-r">
            <!--顶部导航---{-->
            <#include "../topNav.html">
                <!--顶部导航---}-->

                <!--面包屑导航---{-->
                <#if regFlag =1>
                    <#assign moduleName="在网客户">
                        <#else>
                            <#assign moduleName="意向用户">
                </#if>
                <#include "banner.html">
                    <!--面包屑导航---}-->

                    <!--工具栏--{-->
                    <div id="toolbar" class="clearfix">
                        <#if esd  == auth_user.userType.code>
                            <div class="toolbor-module export" style="margin-top:14">
                                <input type="button" onclick="exportxls()" value="<#if regFlag =0>意向<#else>在网</#if>用户导出" class="input-button export-btn"/>
                            </div>
                        </#if>

                        <#if fd  == auth_user.userType.code>
                            <div class="v" style="float:left; margin-top: 15px; margin-left:22px;">
                                理财经理：
                                <select id="fmId" name="fmId" style="min-width:124px; color:#000; height:26px;" class="search-value">
                                    <#if fdList??>
                                        <#list fdList as item>
                                            <#if item??>
                                                <option value="${item.userId}" >${item.realname!''}</option>
                                            </#if>
                                        </#list>
                                    </#if>
                                </select>
                            </div>
                            <div class="toolbor-module search"  style="float:left;">
                                <a id="batchchange" href="javascript:void(0);" class="input-button">批量更改</a>
                            </div>
                        </#if>

                        <#if regFlag =0>
                            <div class="toolbor-module search">
                                <a href="addCustomer.html" class="input-button">+新增客户</a>
                            </div>
                        </#if>

                        <div class="toolbor-module search">

                            <#if fd  == auth_user.userType.code>
                                <div class="formTit">
                                    理财经理：
                                </div>
                                <select id="fmUserId" name="fmUserId" style="min-width:124px; color:#000; height:24px;" class="search-value">
                                    <option value="0">全部</option>
                                    <#if fdList??>
                                        <#list fdList as item>
                                            <#if item??>
                                                <option value="${item.userId}" <#if item.userId ==fmUserId>selected<#else></#if>>${item.realname!''}</option>
                                            </#if>
                                        </#list>
                                    </#if>
                                </select>
                            </#if>

                            <#if regFlag == 0 && fm  == auth_user.userType.code>
                                <div class="formTit">
                                    <a id="oneKeySyn" href="javascript:void(0);" class="input-button">一键同步</a>
                                </div>
                            </#if>
                            <div class="formTit">开始日期：</div><input id="startDate" type="text" name="startDate" style="width:125px;padding:0 10px;height:18px;line-height:18px;float:left" onclick="change_picktime('yyyy-MM-dd')" readonly/>
                            <div class="formTit">结束日期：</div><input id="endDate" type="text" name="endDate" style="width:125px;height:18px;line-height:18px;float:left" onclick="change_picktime('yyyy-MM-dd')" readonly/>

                            <div class="formTit">姓名 /身份证/手机：</div>
                            <input type="text" name="searchName" id="searchName" class="search-value">
                            <input type="button" value="搜索"  class="input-button" onclick="sousuo();">

                        </div>


                    </div>


                    <!--工具栏--}-->

                    <div id="main" class="clearfix">
                        <form id="batchForm" action="/admin/crm/batchChange.html" method="post">
                            <table class="data-list">
                                <tr class="header">
                                    <#if fd  == auth_user.userType.code> <td><input type="checkbox" id="chk_all"/></td></#if>
                                    <td>客户ID</td>
                                    <#if regFlag =1>
                                        <td>用户名</td>
                                    </#if>
                                    <td>姓名</td>
                                    <td>手机</td>
                                    <td>性别</td>
                                    <td>身份证号码</td>
                                    <td>客户邮箱</td>
                                    <td>创建时间</td>
                                    <td>理财经理</td>

                                    <#if regFlag =1>
                                        <td>注册时间</td>
                                        <td>投资准备金</td>
                                    </#if>
                                    <td>备注</td>
                                    <td>操作</td>
                                </tr>
                                <#list list as item>
                                    <tr class="s">
                                        <#if fd  == auth_user.userType.code> <td><input type="checkbox" value="${item.id?c}"  name="custIds"/></td></#if>
                                        <td>${item.id!0}</td>
                                        <#if regFlag =1>
                                            <td>${item.user.userName!''}</td>
                                        </#if>
                                        <td>${item.custName!''}</td>
                                        <td>${item.phone!''}</td>
                                        <td><#if item.gender==0>保密<#elseif item.gender==1>男<#else>女</#if></td>
                                        <td>${item.identityNumber!''}</td>
                                        <td>${item.email!''}</td>
                                        <td>${(item.createDate)?string("yyyy-MM-dd HH:mm:ss")}</td>
                                        <td><#if item.systemUser??>${item.systemUser.realname!''}</#if></td>


                                        <#if regFlag =1>
                                            <td><#if item.user.addTime ??>${(item.user.addTime)?string("yyyy-MM-dd HH:mm:ss")}<#else>--</#if></td>
                                            <td>${item.user.account.balance!0}</td>
                                        </#if>
                                        <td>${item.memo!''}</td>
                                        <!-- 操作 -->
                                        <td>

                                            <a class="un" href="/admin/crm/addTrackRecord.html?custId=${(item.id!0)?c}&custName=${item.custName!''}&page=${page.currentPage}&searchName=${searchName}">跟踪</a>
                                            <a class="un" href="/admin/crm/showUserTrackRecord.html?custId=${(item.id!0)?c}">查看跟踪记录</a>
                                            <#if regFlag =1>
                                                <a class="un" onclick='alertPop("账户信息","url:get?viewUserDetail.html?userId=${item.user.userId?c}",550,200,"true","","true","text");' href="javascript:void(0)">查看账户详情</a>
                                            </#if>
                                            <#if item.user??>
                                                <#else>
                                                    <a class="un" href="/admin/crm/synCustomer.html?custId=${(item.id!0)?c}&page=${page.currentPage}&searchName=${searchName}">同步</a>
                                            </#if>

                                        </td>

                                    </tr>
                                </#list>
                            </table>
                            <input  type="hidden" id="custfmId" name ="fmId">
                            <input  type="hidden" id="regFlag" name ="regFlag" value='${regFlag}'>
                        </form>


                        <!--底部工具栏--{-->
                        <div id="bottomToolbar" class="clearfix">
                            <div class="other-tool">
                                <dl class="refresh-data">
                                    <dt class="refresh-data-icon"></dt>
                                    <dd><a href="javascript:void(0);" class="refresh-page">刷新数据</a></dd>
                                </dl>
                            </div>
                            <!--翻页系统--{-->
                            <div class="container s_formTit">
                                <#import "../../common/page.html" as pager>
                                    <@pager.pagination page=page url="${pageUrl}" map=param style="style1" />
                            </div>
                            <!--翻页系统--}-->
                        </div>
                        <!--底部工具栏--}-->


                        <script>
                            var url = 'queryCustomer.html?search=true&regFlag=${regFlag}';
                            function sousuo(){
                                var sou = "";
                                var ofp = $("#searchName").val();
                                var fmUserId = $("#fmUserId").val();

                                var startDate = $("#startDate").val();
                                var endDate = $("#endDate").val();

                                if((ofp!=null&&ofp!=""&&ofp!="undefined"&&ofp!="请输入(姓名 /身份证/手机)关键字")){
                                    sou += "&searchName="+ofp;
                                }

                                if(startDate!=null && startDate !=""){
                                    sou+="&startDate="+startDate;
                                }
                                if(endDate!=null && endDate !=""){
                                    sou+="&endDate="+endDate;
                                }
                                if(fmUserId!=null && fmUserId != ""){
                                    sou+="&fmUserId="+fmUserId;
                                }

                                if (sou!=""){
                                    location.href=url+sou;
                                }
                            }

                            $("#searchName")[0].defaultValue=getQueryString("searchName","请输入(姓名 /身份证/手机)关键字");
                            function getQueryString(name,tip){
                                var reg=new  RegExp("(^|&)"+name+"=([^&]*)(&|$)");
                                var r =window.location.search.substr(1).match(reg);
                                if(r!=null)
                                    return  decodeURI(r[2]);
                                return  tip;
                            }



                            function exportxls(){
                                var num='${(page.total)?c}';
                                num=num.replace(",","");
                                if(num>30000){ //条数自己定义，但必须小于65536
                                    alert("数据过多，请选择指定的时间进行数据查询导出！"); //提示信息根据不同的内容注意修改下。
                                    return false;
                                }
                                location.href='queryCustomer.html?export=export&regFlag=${regFlag}';
                            }
                        </script>
                    </div>
        </div>
    </div>
    <div class="mc-b">
        <#include "../foot.html">
    </div>
    <#include "../jsPage.html">
        <script type="text/javascript">
            $("#chk_all").click(function(){
                $("input[name='custIds']").attr("checked",$(this).attr("checked"));
            });
            $("#batchchange").click(function(){
                var flag = false;

                $("input[name='custIds']:checked").each(function() {
                    if($(this).attr("checked")){
                        flag =true;
                        return false
                    }
                });

                if(flag){
                    $("#custfmId").val($("#fmId").val());
                    $("#batchForm").submit();
                }else{
                    alert("请选择更改理财经理的客户!");
                }

            });

            //一键同步
            $("#oneKeySyn").click(function(){
                $.ajax({
                    type:"post",
                    url:"/admin/crm/oneKeySyn.html",
                    async:false,
                    dataType:"json",
                    data:{},
                    success:function(arr){
                        alert('一键同步成功！');
                        location.href="/admin/crm/queryCustomer.html?regFlag=1";
                    }
                });

            });
        </script>
    </body>
</html>